import { Router } from 'express';
import { PerformanceController } from '../../admin/controllers/performanceController';
import { authenticate, authorize } from '../../middleware/auth';
import { ALL_PERMISSIONS } from '../../constants/permissions';

const router = Router();
const performanceController = new PerformanceController();


/**
 * @swagger
 * /api/admin/performances/{id}:
 *   get:
 *     summary: 获取演出详情
 *     tags: [Admin - Performances]
 *     security:
 *       - bearerAuth: []
 *     parameters:
 *       - in: path
 *         name: id
 *         required: true
 *         schema:
 *           type: integer
 *         description: 演出ID
 *     responses:
 *       200:
 *         description: 获取成功
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 code:
 *                   type: integer
 *                   example: 200
 *                 message:
 *                   type: string
 *                   example: 获取演出详情成功
 *                 data:
 *                   $ref: '#/components/schemas/Performance'
 */
router.get('/:id', authenticate, authorize([ALL_PERMISSIONS.PERFORMANCE_READ]), performanceController.getPerformance);

/**
 * @swagger
 * /api/admin/performances:
 *   post:
 *     summary: 创建演出
 *     tags: [Admin - Performances]
 *     security:
 *       - bearerAuth: []
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             type: object
 *             required:
 *               - artistId
 *               - title
 *               - venue
 *               - startTime
 *               - endTime
 *             properties:
 *               artistId:
 *                 type: integer
 *                 description: 艺人ID
 *               title:
 *                 type: string
 *                 description: 演出标题
 *               description:
 *                 type: string
 *                 description: 演出描述
 *               venue:
 *                 type: string
 *                 description: 演出场地
 *               floor:
 *                 type: string
 *                 description: 楼层
 *               startTime:
 *                 type: string
 *                 format: date-time
 *                 description: 开始时间
 *               endTime:
 *                 type: string
 *                 format: date-time
 *                 description: 结束时间
 *               maxCapacity:
 *                 type: integer
 *                 description: 最大容量
 *     responses:
 *       201:
 *         description: 创建成功
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 code:
 *                   type: integer
 *                   example: 200
 *                 message:
 *                   type: string
 *                   example: 创建演出成功
 *                 data:
 *                   $ref: '#/components/schemas/Performance'
 */
router.post('/', authenticate, authorize([ALL_PERMISSIONS.PERFORMANCE_CREATE]), performanceController.createPerformance);

/**
 * @swagger
 * /api/admin/performances/{id}:
 *   put:
 *     summary: 更新演出信息
 *     tags: [Admin - Performances]
 *     security:
 *       - bearerAuth: []
 *     parameters:
 *       - in: path
 *         name: id
 *         required: true
 *         schema:
 *           type: integer
 *         description: 演出ID
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             type: object
 *             properties:
 *               title:
 *                 type: string
 *                 description: 演出标题
 *               description:
 *                 type: string
 *                 description: 演出描述
 *               venue:
 *                 type: string
 *                 description: 演出场地
 *               floor:
 *                 type: string
 *                 description: 楼层
 *               startTime:
 *                 type: string
 *                 format: date-time
 *                 description: 开始时间
 *               endTime:
 *                 type: string
 *                 format: date-time
 *                 description: 结束时间
 *               maxCapacity:
 *                 type: integer
 *                 description: 最大容量
 *               status:
 *                 type: string
 *                 enum: [SCHEDULED, ONGOING, COMPLETED, CANCELLED]
 *                 description: 演出状态
 *     responses:
 *       200:
 *         description: 更新成功
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 code:
 *                   type: integer
 *                   example: 200
 *                 message:
 *                   type: string
 *                   example: 更新演出信息成功
 *                 data:
 *                   $ref: '#/components/schemas/Performance'
 */
router.put('/:id', authenticate, authorize([ALL_PERMISSIONS.PERFORMANCE_UPDATE]), performanceController.updatePerformance);

/**
 * @swagger
 * /api/admin/performances/{id}:
 *   delete:
 *     summary: 删除演出
 *     tags: [Admin - Performances]
 *     security:
 *       - bearerAuth: []
 *     parameters:
 *       - in: path
 *         name: id
 *         required: true
 *         schema:
 *           type: integer
 *         description: 演出ID
 *     responses:
 *       200:
 *         description: 删除成功
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 code:
 *                   type: integer
 *                   example: 200
 *                 message:
 *                   type: string
 *                   example: 删除演出成功
 */
router.delete('/:id', authenticate, authorize([ALL_PERMISSIONS.PERFORMANCE_DELETE]), performanceController.deletePerformance);

/**
 * @swagger
 * /api/admin/performances/statistics:
 *   get:
 *     summary: 获取演出统计信息
 *     tags: [Admin - Performances]
 *     security:
 *       - bearerAuth: []
 *     parameters:
 *       - in: query
 *         name: startDate
 *         schema:
 *           type: string
 *           format: date
 *         description: 开始日期
 *       - in: query
 *         name: endDate
 *         schema:
 *           type: string
 *           format: date
 *         description: 结束日期
 *     responses:
 *       200:
 *         description: 获取成功
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 code:
 *                   type: integer
 *                   example: 200
 *                 message:
 *                   type: string
 *                   example: 获取演出统计信息成功
 *                 data:
 *                   type: object
 *                   properties:
 *                     overview:
 *                       type: object
 *                       properties:
 *                         totalPerformances:
 *                           type: integer
 *                         scheduledPerformances:
 *                           type: integer
 *                         ongoingPerformances:
 *                           type: integer
 *                         completedPerformances:
 *                           type: integer
 *                         cancelledPerformances:
 *                           type: integer
 *                     venueStats:
 *                       type: array
 *                       items:
 *                         type: object
 *                         properties:
 *                           venue:
 *                             type: string
 *                           count:
 *                             type: integer
 *                     dailyStats:
 *                       type: array
 *                       items:
 *                         type: object
 *                         properties:
 *                           date:
 *                             type: string
 *                           count:
 *                             type: integer
 */
router.get('/statistics', authenticate, authorize([ALL_PERMISSIONS.PERFORMANCE_READ]), performanceController.getPerformanceStatistics);

/**
 * @swagger
 * /api/admin/performances:
 *   get:
 *     summary: 获取演出列表
 *     tags: [Admin - Performances]
 *     security:
 *       - bearerAuth: []
 *     parameters:
 *       - in: query
 *         name: page
 *         schema:
 *           type: integer
 *           default: 1
 *         description: 页码
 *       - in: query
 *         name: limit
 *         schema:
 *           type: integer
 *           default: 10
 *         description: 每页数量
 *       - in: query
 *         name: status
 *         schema:
 *           type: string
 *           enum: [SCHEDULED, ONGOING, COMPLETED, CANCELLED]
 *         description: 演出状态
 *       - in: query
 *         name: date
 *         schema:
 *           type: string
 *           format: date
 *         description: 演出日期
 *       - in: query
 *         name: artistId
 *         schema:
 *           type: integer
 *         description: 艺人ID
 *     responses:
 *       200:
 *         description: 获取成功
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 code:
 *                   type: integer
 *                   example: 200
 *                 message:
 *                   type: string
 *                   example: 获取演出列表成功
 *                 data:
 *                   type: object
 *                   properties:
 *                     list:
 *                       type: array
 *                       items:
 *                         $ref: '#/components/schemas/Performance'
 *                     pagination:
 *                       $ref: '#/components/schemas/Pagination'
 */
router.get('/', authenticate, authorize([ALL_PERMISSIONS.PERFORMANCE_READ]), performanceController.getPerformances);
export default router; 